﻿@{
    Layout = "";
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="~/pear/component/pear/css/pear.css" />
    <link rel="stylesheet" href="~/pear/admin/css/other/login.css" />
    <link rel="stylesheet" href="~/pear/admin/css/variables.css" />
    <link rel="stylesheet" href="~/pear/admin/css/reset.css" />
    <script>if (window.self != window.top) { top.location.reload(); }</script>
</head>

<body>
    <div class="login-page" style="background-image: url(/pear/admin/images/background.svg)">
        <div class="layui-row">
            <div class="layui-col-sm6 login-bg layui-hide-xs">
                <img class="login-bg-img" src="~/pear/admin/images/banner.png" alt="" />
            </div>
            <div class="layui-col-sm6 layui-col-xs12 login-form">
                <div class="layui-form">
                    <div class="form-center">
                        <div class="form-center-box">
                            <div class="top-log-title">
                                <img class="top-log" src="~/pear/admin/images/logo.png" alt="" />
                                <span>Pear Admin 4.0</span>
                            </div>
                            <div class="top-desc">
                                以 超 乎 想 象 的 速 度 构 建 内 部 工 具
                            </div>
                            <div style="margin-top: 30px;">
                                <form>
                                    <div class="layui-form-item">
                                        <div class="layui-input-wrap">
                                            <div class="layui-input-prefix">
                                                <i class="layui-icon layui-icon-username"></i>
                                            </div>
                                            <input lay-verify="required" name="account" placeholder="账户" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-wrap">
                                            <div class="layui-input-prefix">
                                                <i class="layui-icon layui-icon-password"></i>
                                            </div>
                                            <input type="password" name="confirmPassword" value=""
                                                   lay-verify="required|confirmPassword" placeholder="密码" autocomplete="off"
                                                   class="layui-input" lay-affix="eye">
                                        </div>
                                    </div>
                                    @*
                                    <div class="tab-log-verification">
                                    <div class="verification-text">
                                    <div class="layui-input-wrap">
                                    <div class="layui-input-prefix">
                                    <i class="layui-icon layui-icon-auz"></i>
                                    </div>
                                    <input lay-verify="required" value="VBJFQ" placeholder="验证码" autocomplete="off"
                                    class="layui-input">
                                    </div>
                                    </div>
                                    <img src="~/pear/admin/images/captcha.gif" alt=""
                                    class="verification-img" />
                                    </div>
                                    <div class="layui-form-item">
                                    <div class="remember-passsword">
                                    <div class="remember-cehcked">
                                    <input type="checkbox" name="like1[write]" lay-skin="primary" title="自动登录">
                                    </div>
                                    </div>
                                    </div>*@
                                    <div class="login-btn">
                                        <button type="submit" lay-submit lay-filter="login" class="layui-btn login">登 录</button>
                                    </div>
                                    @*<div class="other-login">
                                        <div class="other-login-methods">
                                            其他方式
                                        </div>
                                        <div class="greenText">注册账号</div>
                                    </div>*@
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 资 源 引 入 -->
    <script src="~/pear/component/layui/layui.js"></script>
    <script src="~/pear/component/pear/pear.js"></script>
    <script>
        layui.use(['form', 'button', 'popup', 'jquery'], function () {
            var form = layui.form;
            var button = layui.button;
            var popup = layui.popup;
            let $ = layui.jquery;

            // 登录提交
            form.on('submit(login)', function (data) {

                let btnLoad = button.load({
                    elem: '.login'
                });

                 $.ajax({
                        url: '/auth/login/',
                        type: 'post',
                        dataType: 'json',
                        data: data.field,
                        success: function (result) {
                            if (result.code === 200) {
                                popup.success("登录成功", function () {
                                    location.href = "/home.html"
                                });
                            } else {
                                popup.failure(result.message);
                            }
                        },
                        complete:function(){
                            btnLoad.stop();
                        }
                  });

                return false;
            });

            // 读取 localStorage 主题颜色值，初始化 主题
            themeColor();

            // 主题颜色切换
            function themeColor(){
                const variableKey = "--global-primary-color";
                const variableVal = localStorage.getItem("theme-color-color");
                document.documentElement.style.setProperty(variableKey, variableVal);
            }
        })
    </script>
</body>

</html>